package com.neouton.crm.pm.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neouton.common.entity.ActivitiVO;
import com.neouton.crm.entity.SysUserEntity;
import com.neouton.crm.pm.entity.BillingApplyDto;
import com.neouton.crm.pm.entity.PurchaseOrderProductVO;
import com.neouton.crm.pm.entity.PurchaseOrderVO;
import com.neouton.crm.screen.Hander.MapResultHandler;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 合同相关Mapper
 * @Author libingkun
 * @Date 2022年11月30日
 * @Version 1.0
 *          初始化迁移
 */
@Mapper
public interface InternalPurchaseMapper {

    Boolean savePurchaseOrder(@Param("purchaseOrder") PurchaseOrderVO purchaseOrder);

    Boolean savePurchaseOrderProduct(@Param("products") List<PurchaseOrderProductVO> purchaseOrderProducts,
                                     @Param("purchaseOrderId") Integer PurchaseOrderId);

    Boolean updatePurchaseOrder(@Param("purchaseOrder") PurchaseOrderVO purchaseOrder);

    /**
     * 获取当日最大合同单号
     * @return
     */
    Integer getPurchaseOrdeMaxNumByDate();

    /**
     * 更具项目ID获取所有采购信息
     */
    List<PurchaseOrderVO> queryPurchaseOrdersByProjectId(@Param("projectId") Integer projectId);

    /**
     * 更具机会ID获取所有采购信息
     */
    List<PurchaseOrderVO> queryPurchaseOrdersByOpId(@Param("opId") Integer opId);
    /**
     * 更具采购单ID获取采购信息
     * @param purchaseOrdeId
     * @return
     */
    PurchaseOrderVO getPurchaseOrdeInfoById(@Param("purchaseOrdeId") Integer purchaseOrdeId);

    /**
     * 备份采购数据
     * @param purchaseOrder
     * @return
     */
    Boolean backUpPurchaseOrder(@Param("purchaseOrder") PurchaseOrderVO purchaseOrder);

    List<PurchaseOrderVO> getPurOrdeInfoById(int purchaseOrdeId);
    /**
     * 通过审批ID查询现有数据
     * @param approvalId
     * @return
     */
    PurchaseOrderVO queryPurchaseOrderByApprovalId(Integer approvalId);

    /**
     * 通过审批ID查询现有数据
     * @param approvalId
     * @return
     */
    PurchaseOrderVO queryPurchaseOrderHistoryByApprovalId(Integer approvalId);

    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    IPage<PurchaseOrderVO> queryPurchaseOrdesByPage(@Param("page") IPage page,
                                                   @Param("vo") PurchaseOrderVO entity,
                                                   @Param("userList") List<SysUserEntity> userList);


    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    IPage<PurchaseOrderVO> queryApprovalPurByPage(@Param("page") IPage page,
                                                  @Param("vo") PurchaseOrderVO entity,
                                                  @Param("activitis") List<ActivitiVO> activitiVOS);

    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    IPage<PurchaseOrderVO> queryApprovalPurDoneByPage(@Param("page") IPage page,
                                                      @Param("vo") PurchaseOrderVO entity);

    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    IPage<PurchaseOrderVO> queryApprovalPurRecordByPage(@Param("page") IPage page,
                                                        @Param("vo") PurchaseOrderVO entity,
                                                        @Param("userList") List<SysUserEntity> userList);
    /**
     * 分页查询
     *
     * @param page
     * @param entity
     * @return
     */
    List<PurchaseOrderVO> queryPurchaseOrdes(@Param("vo") PurchaseOrderVO entity, @Param("userList") List<SysUserEntity> userList);

    /**
     * 采购单迁移
     * @param projectId 项目ID
     * @param opId 机会ID
     * @return
     */
    void updatePurchaseProjectIdByOpId(@Param("projectId") Integer projectId, @Param("opId") Integer opId);

    Boolean deletePurchaseOrderById(Integer purchaseId);

    List<PurchaseOrderVO> selectAllProjectByPur();
}
